package com.letsiot.applications.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.letsiot.applications.entity.SysResources;
import com.letsiot.applications.repository.SysResourcesMapper;
import com.letsiot.applications.service.SysResourcesService;
import com.letsiot.common.data.IdUtil;

@Service
public class SysResourcesServiceImpl implements SysResourcesService {

    @Autowired
    private SysResourcesMapper sysResourcesMapper;

    @Override
    public int save(SysResources entity) {
        if (entity.getId() == null) {
            entity.setId(IdUtil.getId());
        }
        return sysResourcesMapper.insertSelective(entity);
    }

    @Override
    public int delete(Long id) {
        return sysResourcesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(SysResources entity) {
        return sysResourcesMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public SysResources findById(Long id) {
        return sysResourcesMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysResources> getAll() {
        return sysResourcesMapper.getAll();
    }

    @Override
    public List<SysResources> findBySystemId(Long systemId) {
        return sysResourcesMapper.findBySystemId(systemId);
    }
}
